﻿using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SaleOnlineSystem.Admin.Controls
{
    public partial class EditImageProduct : System.Web.UI.UserControl
    {
        public string image;
        public string name;
        public string discription;
        public string price;
        public string discount;
        public string summary;
        public string cate1_id;
        public string cate2_id;
        public string cate3_id;
        public string idcolor;
        public string colorname;
        public string idsize;
        public string idvendor;
        public string cate1_name;
        public string bigimage;
        public string smallimage;
        public int idproductcolor;
        public string imagesmall1;
        public string imagesmall2;
        public string imagesmall3;
        public LIB.Validate saveimage;
        public string filePathBigIamge;
        public string filePathSmallIamge;
        public string linkimgsmall;
        public string linkimgbigimage;
        public string productname;
        protected void Page_Load(object sender, EventArgs e)
        {
            idproductcolor = Convert.ToInt32(Request.QueryString["idproductcolor"]);
            DataTable dt = DAL.DCollector.DBCollector.Instance.SelectSQL("Select * from tbl_ProductColor,tbl_Color,tbl_Product Where tbl_ProductColor.Color_ID = tbl_Color.Color_ID AND tbl_ProductColor.ProductColor_ID=" + idproductcolor + " AND tbl_ProductColor.Product_ID = tbl_Product.Product_ID");
            productname = dt.Rows[0]["Product_Name"].ToString();
            linkimgbigimage = dt.Rows[0]["Product_ImageColor"].ToString();
            linkimgsmall = dt.Rows[0]["Product_MultiImage"].ToString();
            colorname = dt.Rows[0]["Color_Name"].ToString();

            string[] splitimagesmall = linkimgsmall.Split(',');
            imagesmall1 = splitimagesmall[0].ToString();
            imagesmall2 = splitimagesmall[1].ToString();
            imagesmall3 = splitimagesmall[2].ToString();
        }

        protected void btnUpdateProduct_Click(object sender, EventArgs e)
        {
            if (fulBigImage.HasFile && fulSmallImage1.HasFile && fulSmallImage2.HasFile && fulSmallImage3.HasFile)
            {
                if (LIB.Validate.CheckFileType(fulBigImage.FileName))
                {
                    if (LIB.Validate.CheckFileType(fulSmallImage1.FileName))
                    {
                        if (LIB.Validate.CheckFileType(fulSmallImage2.FileName))
                        {
                            if (LIB.Validate.CheckFileType(fulSmallImage3.FileName))
                            {
                                saveimage = new LIB.Validate();

                                filePathBigIamge = "/Images/Image-Products/" + idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName) + "";
                                filePathSmallIamge = "/Images/Image-Products/" + idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName) + ",/Images/Image-Products/" + idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName) + ",/Images/Image-Products/" + idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName) + "";
                                saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName), 500, fulBigImage.PostedFile.InputStream);
                                saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName), 500, fulSmallImage1.PostedFile.InputStream);
                                saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName), 500, fulSmallImage2.PostedFile.InputStream);
                                saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName), 500, fulSmallImage3.PostedFile.InputStream);
                                DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[2];

                                cl[0] = new DAL.DHelpers.Column("Product_ImageColor", filePathBigIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);
                                cl[1] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                                string[] colWhere = new string[1];
                                colWhere[0] = "ProductColor_ID";

                                object[] colValue = new object[1];
                                colValue[0] = idproductcolor;

                                DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                                Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                            }
                            else
                            {
                                Response.Write("<script>alert('Ảnh nhỏ 3 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                            }
                        }
                        else
                        {
                            Response.Write("<script>alert('Ảnh nhỏ 2 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                        }
                    }

                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 1 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ lớn chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if (fulBigImage.HasFile && fulSmallImage1.HasFile && (fulSmallImage2.HasFile == false) && (fulSmallImage3.HasFile == false))
            {
                if (LIB.Validate.CheckFileType(fulBigImage.FileName))
                {
                    if (LIB.Validate.CheckFileType(fulSmallImage1.FileName))
                    {
                        saveimage = new LIB.Validate();
                        filePathBigIamge = "/Images/Image-Products/" + idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName) + "";
                        filePathSmallIamge = "/Images/Image-Products/" + idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName) + "," + imagesmall2 + "," + imagesmall3 + "";
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName), 500, fulBigImage.PostedFile.InputStream);
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName), 500, fulSmallImage1.PostedFile.InputStream);
                        DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[2];

                        cl[0] = new DAL.DHelpers.Column("Product_ImageColor", filePathBigIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);
                        cl[1] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                        string[] colWhere = new string[1];
                        colWhere[0] = "ProductColor_ID";

                        object[] colValue = new object[1];
                        colValue[0] = idproductcolor;

                        DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                        Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                    }
                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 1 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ lớn chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if (fulBigImage.HasFile && fulSmallImage1.HasFile && (fulSmallImage2.HasFile == false) && fulSmallImage3.HasFile)
            {
                if (LIB.Validate.CheckFileType(fulBigImage.FileName))
                {

                    if (LIB.Validate.CheckFileType(fulSmallImage1.FileName))
                    {
                        if (LIB.Validate.CheckFileType(fulSmallImage3.FileName))
                        {
                            saveimage = new LIB.Validate();
                            filePathBigIamge = "/Images/Image-Products/" + idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName) + "";
                            filePathSmallIamge = "/Images/Image-Products/" + idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName) + "," + imagesmall2 + ",/Images/Image-Products/" + idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName) + "";
                            saveimage = new LIB.Validate();
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "a" + Path.GetExtension(fulBigImage.FileName), 500, fulBigImage.PostedFile.InputStream);
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName), 500, fulSmallImage1.PostedFile.InputStream);
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName), 500, fulSmallImage3.PostedFile.InputStream);
                            DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[2];

                            cl[0] = new DAL.DHelpers.Column("Product_ImageColor", filePathBigIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);
                            cl[1] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                            string[] colWhere = new string[1];
                            colWhere[0] = "ProductColor_ID";

                            object[] colValue = new object[1];
                            colValue[0] = idproductcolor;

                            DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                            Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                        }
                        else
                        {
                            Response.Write("<script>alert('Ảnh nhỏ 3 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 1 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ lớn chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if (fulBigImage.HasFile && fulSmallImage1.HasFile && fulSmallImage2.HasFile && (fulSmallImage3.HasFile == false))
            {
                if (LIB.Validate.CheckFileType(fulBigImage.FileName))
                {
                    if (LIB.Validate.CheckFileType(fulSmallImage1.FileName))
                    {
                        if (LIB.Validate.CheckFileType(fulSmallImage2.FileName))
                        {
                            saveimage = new LIB.Validate();
                            filePathBigIamge = "/Images/Image-Products/" + idproductcolor + "a" + Path.GetExtension(fulBigImage.FileName) + "";
                            filePathSmallIamge = "/Images/Image-Products/" + idproductcolor + "b" + Path.GetExtension(fulSmallImage1.FileName) + ",/Images/Image-Products/" + idproductcolor + "c" + Path.GetExtension(fulSmallImage2.FileName) + "," + imagesmall3 + "";
                            saveimage = new LIB.Validate();
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/" + cate1_name + "/"), idproductcolor + "a" + Path.GetExtension(fulBigImage.FileName), 500, fulBigImage.PostedFile.InputStream);
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/" + cate1_name + "/"), idproductcolor + "b" + Path.GetExtension(fulSmallImage1.FileName), 500, fulSmallImage1.PostedFile.InputStream);
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/" + cate1_name + "/"), idproductcolor + "c" + Path.GetExtension(fulSmallImage2.FileName), 500, fulSmallImage2.PostedFile.InputStream);
                            DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[2];

                            cl[0] = new DAL.DHelpers.Column("Product_ImageColor", filePathBigIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);
                            cl[1] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                            string[] colWhere = new string[1];
                            colWhere[0] = "ProductColor_ID";

                            object[] colValue = new object[1];
                            colValue[0] = idproductcolor;

                            DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                            Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                        }
                        else
                        {
                            Response.Write("<script>alert('Ảnh nhỏ 2 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 1 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ lớn chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if (fulBigImage.HasFile && (fulSmallImage1.HasFile == false) && fulSmallImage2.HasFile && fulSmallImage3.HasFile)
            {
                if (LIB.Validate.CheckFileType(fulBigImage.FileName))
                {
                    if (LIB.Validate.CheckFileType(fulSmallImage2.FileName))
                    {
                        if (LIB.Validate.CheckFileType(fulSmallImage3.FileName))
                        {
                            saveimage = new LIB.Validate();
                            filePathBigIamge = "/Images/Image-Products/" + cate1_name + "/" + idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName) + "";
                            filePathSmallIamge = "" + imagesmall1 + ",/Images/Image-Products/" + idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName) + ",/Images/Image-Products/" + idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName) + "";
                            saveimage = new LIB.Validate();
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName), 500, fulBigImage.PostedFile.InputStream);
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName), 500, fulSmallImage2.PostedFile.InputStream);
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName), 500, fulSmallImage3.PostedFile.InputStream);
                            DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[2];

                            cl[0] = new DAL.DHelpers.Column("Product_ImageColor", filePathBigIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);
                            cl[1] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                            string[] colWhere = new string[1];
                            colWhere[0] = "ProductColor_ID";

                            object[] colValue = new object[1];
                            colValue[0] = idproductcolor;

                            DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                            Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                        }
                        else
                        {
                            Response.Write("<script>alert('Ảnh nhỏ 3 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 2 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ lớn chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if (fulBigImage.HasFile && (fulSmallImage1.HasFile == false) && fulSmallImage2.HasFile && (fulSmallImage3.HasFile == false))
            {
                if (LIB.Validate.CheckFileType(fulBigImage.FileName))
                {
                    if (LIB.Validate.CheckFileType(fulSmallImage2.FileName))
                    {
                        saveimage = new LIB.Validate();
                        filePathBigIamge = "/Images/Image-Products/" + idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName) + "";
                        filePathSmallIamge = "" + imagesmall1 + ",/Images/Image-Products/" + idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName) + "," + imagesmall3 + "";
                        saveimage = new LIB.Validate();
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName), 500, fulBigImage.PostedFile.InputStream);
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName), 500, fulSmallImage2.PostedFile.InputStream);
                        DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[2];

                        cl[0] = new DAL.DHelpers.Column("Product_ImageColor", filePathBigIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);
                        cl[1] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                        string[] colWhere = new string[1];
                        colWhere[0] = "ProductColor_ID";

                        object[] colValue = new object[1];
                        colValue[0] = idproductcolor;

                        DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                        Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                    }
                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 2 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ lớn chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if (fulBigImage.HasFile && (fulSmallImage1.HasFile == false) && (fulSmallImage2.HasFile == false) && fulSmallImage3.HasFile)
            {
                if (LIB.Validate.CheckFileType(fulBigImage.FileName))
                {
                    if (LIB.Validate.CheckFileType(fulSmallImage3.FileName))
                    {
                        saveimage = new LIB.Validate();
                        filePathBigIamge = "/Images/Image-Products/" + idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName) + "";
                        filePathSmallIamge = "" + imagesmall1 + "," + imagesmall2 + ",/Images/Image-Products/" + idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName) + "";
                        saveimage = new LIB.Validate();
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName), 500, fulBigImage.PostedFile.InputStream);
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName), 500, fulSmallImage3.PostedFile.InputStream);
                        DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[2];

                        cl[0] = new DAL.DHelpers.Column("Product_ImageColor", filePathBigIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);
                        cl[1] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                        string[] colWhere = new string[1];
                        colWhere[0] = "ProductColor_ID";

                        object[] colValue = new object[1];
                        colValue[0] = idproductcolor;

                        DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                        Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                    }
                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 2 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ lớn chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if (fulBigImage.HasFile && (fulSmallImage1.HasFile == false) && (fulSmallImage2.HasFile == false) && (fulSmallImage3.HasFile == false))
            {
                if (LIB.Validate.CheckFileType(fulBigImage.FileName))
                {
                    saveimage = new LIB.Validate();
                    filePathBigIamge = "/Images/Image-Products/" + idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName) + "";
                    saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "b" + Path.GetExtension(fulBigImage.FileName), 500, fulBigImage.PostedFile.InputStream);
                    DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[1];

                    cl[0] = new DAL.DHelpers.Column("Product_ImageColor", filePathBigIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                    string[] colWhere = new string[1];
                    colWhere[0] = "ProductColor_ID";

                    object[] colValue = new object[1];
                    colValue[0] = idproductcolor;

                    DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                    Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                }

                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ lớn chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            //------------------------------------------------------------------------------------------------------------------------

            if ((fulBigImage.HasFile == false) && fulSmallImage1.HasFile && fulSmallImage2.HasFile && fulSmallImage3.HasFile)
            {
                if (LIB.Validate.CheckFileType(fulSmallImage1.FileName))
                {
                    if (LIB.Validate.CheckFileType(fulSmallImage2.FileName))
                    {
                        if (LIB.Validate.CheckFileType(fulSmallImage3.FileName))
                        {
                            saveimage = new LIB.Validate();                            
                            filePathSmallIamge = "/Images/Image-Products/" + idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName) + ",/Images/Image-Products/" + idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName) + ",/Images/Image-Products/" + idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName) + "";                           
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName), 500, fulSmallImage1.PostedFile.InputStream);
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName), 500, fulSmallImage2.PostedFile.InputStream);
                            saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName), 500, fulSmallImage3.PostedFile.InputStream);
                            DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[1];

                            cl[0] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                            string[] colWhere = new string[1];
                            colWhere[0] = "ProductColor_ID";

                            object[] colValue = new object[1];
                            colValue[0] = idproductcolor;

                            DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                            Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                        }
                        else
                        {
                            Response.Write("<script>alert('Ảnh nhỏ 3 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 2 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }

                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ 1 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if ((fulBigImage.HasFile == false) && fulSmallImage1.HasFile && (fulSmallImage2.HasFile == false) && (fulSmallImage3.HasFile == false))
            {
                if (LIB.Validate.CheckFileType(fulSmallImage1.FileName))
                {
                    saveimage = new LIB.Validate();
                    filePathSmallIamge = "/Images/Image-Products/" + idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName) + "," + imagesmall2 + "," + imagesmall3 + "";                  
                    saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName), 500, fulSmallImage1.PostedFile.InputStream);
                    DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[1];

                    cl[0] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                    string[] colWhere = new string[1];
                    colWhere[0] = "ProductColor_ID";

                    object[] colValue = new object[1];
                    colValue[0] = idproductcolor;

                    DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                    Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ 1 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if ((fulBigImage.HasFile == false) && fulSmallImage1.HasFile && (fulSmallImage2.HasFile == false) && fulSmallImage3.HasFile)
            {
                if (LIB.Validate.CheckFileType(fulSmallImage1.FileName))
                {
                    if (LIB.Validate.CheckFileType(fulSmallImage3.FileName))
                    {
                        saveimage = new LIB.Validate();
                        filePathSmallIamge = "/Images/Image-Products/" + idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName) + "," + imagesmall2 + ",/Images/Image-Products/" + idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName) + "";
                                               
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName), 500, fulSmallImage1.PostedFile.InputStream);
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName), 500, fulSmallImage3.PostedFile.InputStream);
                        DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[1];

                        cl[0] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                        string[] colWhere = new string[1];
                        colWhere[0] = "ProductColor_ID";

                        object[] colValue = new object[1];
                        colValue[0] = idproductcolor;

                        DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                        Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                    }
                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 3 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ 1 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if ((fulBigImage.HasFile == false) && fulSmallImage1.HasFile && fulSmallImage2.HasFile && (fulSmallImage3.HasFile == false))
            {
                if (LIB.Validate.CheckFileType(fulSmallImage1.FileName))
                {
                    if (LIB.Validate.CheckFileType(fulSmallImage2.FileName))
                    {
                        saveimage = new LIB.Validate();
                        filePathSmallIamge = "/Images/Image-Products/" + idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName) + ",/Images/Image-Products/" + idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName) + "," + imagesmall3 + "";
                                                
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "c" + Path.GetExtension(fulSmallImage1.FileName), 500, fulSmallImage1.PostedFile.InputStream);
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName), 500, fulSmallImage2.PostedFile.InputStream);
                        DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[1];

                        cl[0] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                        string[] colWhere = new string[1];
                        colWhere[0] = "ProductColor_ID";

                        object[] colValue = new object[1];
                        colValue[0] = idproductcolor;

                        DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                        Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                    }
                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 2 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ 1 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if ((fulBigImage.HasFile == false) && (fulSmallImage1.HasFile == false) && fulSmallImage2.HasFile && fulSmallImage3.HasFile)
            {
                if (LIB.Validate.CheckFileType(fulSmallImage2.FileName))
                {
                    if (LIB.Validate.CheckFileType(fulSmallImage3.FileName))
                    {
                        saveimage = new LIB.Validate();
                        filePathSmallIamge = "" + imagesmall1 + ",/Images/Image-Products/" + idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName) + ",/Images/Image-Products/" + idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName) + "";                                         
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName), 500, fulSmallImage2.PostedFile.InputStream);
                        saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName), 500, fulSmallImage3.PostedFile.InputStream);
                        DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[1];

                        cl[0] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                        string[] colWhere = new string[1];
                        colWhere[0] = "ProductColor_ID";

                        object[] colValue = new object[1];
                        colValue[0] = idproductcolor;

                        DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                        Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                    }
                    else
                    {
                        Response.Write("<script>alert('Ảnh nhỏ 3 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ 2 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if ((fulBigImage.HasFile == false) && (fulSmallImage1.HasFile == false) && fulSmallImage2.HasFile && (fulSmallImage3.HasFile == false))
            {
                if (LIB.Validate.CheckFileType(fulSmallImage2.FileName))
                {
                    saveimage = new LIB.Validate();
                    filePathSmallIamge = "" + imagesmall1 + ",/Images/Image-Products/" + idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName) + "," + imagesmall3 + "";
                    
                    
                    saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "d" + Path.GetExtension(fulSmallImage2.FileName), 500, fulSmallImage2.PostedFile.InputStream);
                    DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[1];

                    cl[0] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                    string[] colWhere = new string[1];
                    colWhere[0] = "ProductColor_ID";

                    object[] colValue = new object[1];
                    colValue[0] = idproductcolor;

                    DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                    Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ 2 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }

            if ((fulBigImage.HasFile == false) && (fulSmallImage1.HasFile == false) && (fulSmallImage2.HasFile == false) && fulSmallImage3.HasFile)
            {
                if (LIB.Validate.CheckFileType(fulSmallImage3.FileName))
                {
                    saveimage = new LIB.Validate(); 
                    filePathSmallIamge = "" + imagesmall1 + "," + imagesmall2 + ",/Images/Image-Products/" + idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName) + "";
                                      
                    saveimage.ThayDoiKichThuocAnh(Server.MapPath("/Images/Image-Products/"), idproductcolor + "e" + Path.GetExtension(fulSmallImage3.FileName), 500, fulSmallImage3.PostedFile.InputStream);
                    DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[1];

                    cl[0] = new DAL.DHelpers.Column("Product_MultiImage", filePathSmallIamge, DAL.DHelpers.DataType.DataTypeSql.Varchar);

                    string[] colWhere = new string[1];
                    colWhere[0] = "ProductColor_ID";

                    object[] colValue = new object[1];
                    colValue[0] = idproductcolor;

                    DAL.DCollector.DBCollector.Instance.Update("tbl_ProductColor", cl, colWhere, colValue);
                    Response.Redirect("/Admin/Index.aspx?panel=1&sub=9&idproductcolor=" + idproductcolor);
                }
                else
                {
                    Response.Write("<script>alert('Ảnh nhỏ 2 chỉ có thể upload file(.jpg,.png,.jpeg)')</script>");
                }
            }            
        }
    }
}